Repository navigation
Conversation
Do not merge: experiment for evaluating direct altimate-code tools in Claude Code. - Bring in `altimate-code mcp serve` and the workspace tools from the MCP draft branches - `tool list|schema|run|context|daemon`: run the same adapter as `mcp serve` without a model - `mcp serve` default set adds impact, lineage, PII, data-diff, equivalence and translation tools; `--all-tools` exposes the full allow-list - Long-running per-project process keeps connections warm and releases DuckDB/SQLite file locks between calls - `--connections` / `ALTIMATE_TOOL_CONNECTIONS`, `--args -` from stdin, `tool schema` for one tool - DROP DATABASE, DROP SCHEMA and TRUNCATE stay blocked even with `--allow-write` - `link --claude-md` writes CLI routing guidance for clients without MCP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Do not merge: experiment. - `tool list|schema|run|context|daemon` enable workspace tools automatically when the project is linked; `--no-workspace-tools` disables them - `tool context` lists the linked workspace, its skills and how to use the workspace tools - Daemon identity and spawn arguments follow the effective workspace-tools value Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ills Do not merge: experiment. - Every workspace skill sync also writes the skills into `<project>/.claude/skills/`, so linking or refreshing a project puts them on disk before a Claude Code session starts - Copies follow the Claude Code plugin's rules: frontmatter reduced to `name` and `description`, command blocks neutralised, hook and plugin component paths skipped, user-written skills never touched, each copy marked and git-ignored - Unlink and the feature-off path remove the copies; projects without `.claude` are left alone; `ALTIMATE_CLAUDE_SKILL_SYNC=0` disables it - A mirror failure never changes the sync result - Tests: `claude-skill-mirror.test.ts`, mirror wiring in `skill-sync.test.ts` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # packages/opencode/src/altimate/api/client.ts
…ll mirror - daemon: release file locks when the last request finishes; serialize bind and stale-socket recovery with a lock; clients never unlink sockets; refuse a symlinked or foreign-owned socket directory - mcp: warehouse_remove and driver installs need --allow-write over MCP too - analyst effort: a per-model effort or thinking option wins over the default - adapter: bound the answer_commit history kept across turns - tool CLI: keep spilled results under the state directory, not /tmp - skill mirror: skip a symlinked .claude or .claude/skills; swap copies without deleting the old one first - docs: callers in one directory share the daemon Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Detects gh, jira-cli, env tokens and Claude MCP servers, syncs them to the Altimate workspace or keeps them in the OS keychain, and connects a provider through a browser consent flow with a loopback callback. Expired tokens are re-created through the authorize flow; no refresh token is stored. Disconnect also removes the workspace copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Pre-merge checks:
|
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
…cking files Files that reset the native dispatcher or mock the MCP SDK client modules now restore them, so tests that run later in the same process see the real ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…space skill mirror Copies carry a marker naming the skill, so a renamed copy is the user's; nested CLAUDE.md files are not copied; staging uses an .altimate-staging- infix, gets its .gitignore first and is swept when abandoned; an unreadable snapshot, or one missing while it is swapped, leaves the copies alone; and the mirror and the plugin's sync take turns under one mkdir lock in .claude/skills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # packages/opencode/src/altimate/api/client.ts # packages/opencode/src/memory/store.ts
…uard read-only warehouse_add - daemon: reload connections when a connections file changes, only when no other call is in flight, with calls arriving during a reload waiting for it; key the socket on the caller's ALTIMATE_CODE_CONN_* environment; resolve --connections once - registry: validate a connections file before closing anything; never release in-memory DuckDB/SQLite connections - mcp serve: release file database locks when no call is in flight - warehouse_add: a read-only session cannot replace a connection named in the active registry, the global or project file, or the credential store - adapter: bound the answer_commit history on every call, not only on commit - skill mirror: keep copies when the snapshot or a skill cannot be read; let withdrawal run with ALTIMATE_CLAUDE_SKILL_SYNC=0 - tool CLI: decide the workspace tools default from the saved link, without a network call - workspace-client: telemetry name and disabled-workspace stub - docs and help text for the daemon, workspace tools and --all-tools Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nder concurrent and partial reads The mkdir lock shared with the plugin is renewed by its holder, taken over from a dead one by rename, released only by the holder (an empty token directory), and never waited on past its deadline; a holder that lost it stops before the next swap. The manifest is read without following symlinks and re-read before the removal pass; a listed skill directory that is gone, or credentials that exist but cannot be read, change nothing. One skill's failed swap no longer stops the others; tree comparison streams one file pair at a time; frontmatter whitespace matches Python's; readManifest rejects a skills array. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
connect now asks for the same fields as the workspace web form, read from the integrations catalog, pre-filled from credentials found on the machine. Secrets come from detection, the clipboard, an env var or stdin and are never printed. Credentials are validated directly with GitHub, Jira or Linear, then kept in the keychain or synced to the workspace. A rejected token can be updated on the same connection. The browser OAuth flow moves behind connect --oauth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and withdraw them on sign-out Each copy is swapped in only while the lock is held and the snapshot is the one read and still the signed-in account's, so a mid-copy swap, takeover or sign-out publishes nothing. Swap detection uses the staging directory's mtime, which a rename updates on every platform. A SKILL.md that is not a regular file skips that skill instead of freezing every sync; markers decode strictly with their BOM kept, as the plugin's Python reads them. The sync waits at most 2 s for the lock. Signing out withdraws the project's copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saving, updating, listing and removing a workspace connection now use the existing /connections endpoints, so no backend change is needed. The browser OAuth flow is removed; credentials are always the workspace's own fields, validated with the provider first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts check and its read The plugin's copy treats that as a snapshot changing underneath and changes nothing; the mirror dropped the skill instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saving a GitHub, Jira or Linear credential (connect, update or sync) now also attaches the connection to the project's linked workspace, so it shows on the workspace's integrations. A new entry enables only read-only tools. Sync re-attaches a connection already saved to the account when no local secret is kept. A workspace the caller does not own is reported clearly. The workspace commands honour ALTIMATE_API_URL, ALTIMATE_TENANT and ALTIMATE_TOKEN like the integrations client, so a local backend works end to end, and sync/status report the real tenant and workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… every copy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
status and sync --json now include `linked` and the linked workspace `id`, so clients can offer to link an unlinked project instead of showing the tenant name as if it were a workspace. The human header says when the project is not linked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-integrations-sync
…e tools - `daemon`: requests wait for an in-progress file release, `stop` replies before shutting down, and the daemon key includes `ALTIMATE_DISABLE_SCHEMA_VALUES`, `ALTIMATE_INTEGRATIONS` and `ALTIMATE_DISABLE_WORKSPACE`. - `permissions`: the blocked-statement check runs before the read-permission shortcut. - `claude-md`: a symlinked `CLAUDE.md` is left untouched. - `workspace-tools`: workspace-authored names and descriptions render as one inert line, skills are read through `WorkspaceClient.readSkill`, and the workspace is labelled with `workspaceLabel`. - MCP workspace adapter: an adapter is closed only after the operations using it finish; `serverInstructions` releases file connections it opened. - `outputLimits` reads organisation-managed config and preferences. - `schema-list`: MySQL and Redshift (whose drivers ignore binds) get an escaped schema literal; schema names are sorted before the limit. - `registry.releaseFileConnections` keeps remote and in-memory URI stores. - `sql_execute` batches: `truncated` reports row-limited or clipped items, references resolve against the default warehouse, duplicate labels are rejected, backslashes are escaped for BigQuery, Snowflake, Databricks and ClickHouse, and an unmaterialized spill returns no table. - `answer_commit`: integers keep every digit; coverage and number checks stand down when the run budget is ending (one shared `budgetEnding`). - `warehouse_add` resolves relative store paths against the project root; `warehouse_list` skips only workspace-routed connections in discovery. - `analyst-effort` honours SAP `modelParams` and the configured `model.variants`. - Workspace client: `readSkill` opens with `O_NOFOLLOW`; context lists only skills with a regular `SKILL.md`. `releaseLocalSession` clears every per-session map; skill withdrawal runs in `finally` on purge. - MongoDB `listTables` checks that an empty database exists. - Docs and `--allow-write` help match the actual policies. - Tests for each behaviour change; new suites restore their spies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ferences BigQuery and Spark/Databricks have no `''` escape inside a string literal (Databricks reads `'it''s'` as two adjacent literals, `its`). Batch references now escape the quote with a backslash for those two dialects and keep `''` for the rest. The read-only check does not lex their backslash escape, so such a step is refused instead of running with a wrong value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rules; address review findings - data_diff refuses any source, target or where_clause that is not one complete read-only query (classifier read, single statement, balanced parentheses, no side-effect or dynamic query() calls) before connecting, checks every statement it runs, and opens every connector read-only. sql_check keeps its stricter rules (shared read-only-sql helper). - isBlockedStatement classifies the whole pattern, so leading comments and multi-statement patterns stay hard-blocked. - Redshift values in batch references get their backslashes escaped. - Tool daemon: the idle timer waits for a pending file release; only a request that ran a tool leads to a release, and a stop is answered without waiting for one; the socket is owner-only. - Workspace: refresh clears the active adapter before closing it; a snapshot removed mid-read lists no skills; copies into .claude/skills are opt-in with ALTIMATE_CLAUDE_SKILL_SYNC=1 (the Claude Code plugin sets it). - Analyst effort ignores non-object model params and output_config without effort; managed output preferences resolve files against their own directory; warehouse_add shares the registry's project root; mcp --allow-write help names the hard blocks. - Docs for warehouse_add's local writes, Claude Code skill copies, analyst effort and answer_commit; tests for each change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…code configs count when deciding who may use the shell token, and a recorded connection id is used only on the backend it was recorded for Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r GH_TOKEN, and gh is asked for its own github.com login without them, so a token for another host cannot reach api.github.com A token in those variables may be for any host, and every attempt to tell which from the surrounding MCP and settings files left another place unread. GitHub tokens now come only from gh's stored github.com login, GitHub's official MCP setups, or a token entered here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emoved, so a failed removal can be retried, and detection reads Claude Code's config from CLAUDE_CONFIG_DIR Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd MCP args that are not a list never crash detection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…another Altimate sign-in, and gh's active github.com login is found even beside an expired account Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s program, every save refuses while the copy is on another sign-in, disconnect needs a sign-in for a recorded copy, and a leftover remembers its secret fields Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is on another sign-in, and leftover field handling is pinned on both paths Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tatus say a connection is on another sign-in instead of calling it removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… view Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
1 similar comment
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
Ready for re-review at
|
| throw new Error(`${PROVIDER_NAMES[id]} is saved in your workspace. Sign in to Altimate to remove it, then disconnect again.`) | ||
| // Nothing is forgotten here while its workspace copy sits on a backend this login cannot reach. | ||
| const elsewhere = recordedElsewhere(id, login) | ||
| if (elsewhere) throw new Error(elsewhere) |
There was a problem hiding this comment.
WARNING: A recorded backend key that cannot be reproduced leaves the local credential undeletable
recordedElsewhere only clears when backendKey(cfg) matches the stored connectionBackend exactly (apiUrl#tenant). If that key can never come back — the tenant/org was renamed or deleted, or the record was written while ALTIMATE_INTEGRATIONS_API_URL/ALTIMATE_INTEGRATIONS_TENANT were set and that override is now gone — this throws, connect refuses at credentials.ts:780 and :884, and sync refuses at core.ts:1203 and :1248. The secret then stays on disk with no CLI path to remove it (only hand-editing integrations.json), while block does not delete secrets either. Consider letting disconnect fall back to the local purge when the recorded copy cannot be reached (or an explicit override), so a stale key is not a dead end.
There was a problem hiding this comment.
Fixed in 6a68750. disconnect <provider> --local-only removes the credential from this machine only and makes no workspace call, so a recorded sign-in that can never come back is not a dead end. The "another Altimate sign-in" refusal now names it. There's a test for it, and the CLI help lists the flag.
| const own = backend.ownConnections(visible) | ||
| // The workspace decides whether the connection is usable, not the flag kept here from an earlier check. | ||
| // A recorded id names a connection only on the backend it was recorded for. | ||
| const sameBackend = (store.providers[id]?.connectionBackend ?? backendKey(cfg)) === backendKey(cfg) |
There was a problem hiding this comment.
SUGGESTION: sameBackend duplicates recordedElsewhere
When known != null, knownFor (line 1187) has already established connectionId != null, and both loadStore() reads happen back-to-back with no await between them, so sameBackend === false implies recordedElsewhere(...) is non-null and line 1203 has already returned. The : undefined branch of the ternary at line 1204 is therefore unreachable, and two checks derive the same backend comparison from two separate store reads. Dropping sameBackend and always using own.find((c) => c.id === known && c.integration_id === INTEGRATION_IDS[id]) keeps the behavior identical.
There was a problem hiding this comment.
Done in 6a68750. sameBackend is dropped. recordedElsewhere already returns before that point whenever the backends differ, so the lookup by recorded id is unconditional.
| * written, that the leftover is not recorded. | ||
| */ | ||
| /** Which backend and tenant a connection id belongs to: the same id elsewhere is another connection. */ | ||
| /** Why a workspace copy cannot be removed from the backend signed in to: it was recorded on another one. Null when it can. */ |
There was a problem hiding this comment.
SUGGESTION: The doc comments no longer sit on the functions they describe
Inserting recordedElsewhere left the neighbouring blocks where they were: the recordLeftover doc at lines 960-964 now documents recordedElsewhere, the backendKey one-liner at line 965 is orphaned above it, and backendKey at line 973 has no doc at all. Move line 965 down to 973 and lines 960-964 down to 975.
There was a problem hiding this comment.
Done in 6a68750. The recordedElsewhere, backendKey and recordLeftover doc comments now sit on their own functions.
…gn-in can't come back, and the cross-sign-in check and doc comments are tidied Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…P server's own token key is the only one read, Keep local remembers old fields it could not remove, and the repository-file note points at connect Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…amed from the environment is refused beside another host, and an update after a host name change updates the recorded connection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and a save keeps a draft entered again while it ran Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oves only the drafts it used while unchanged, and a connection the user renamed keeps its name Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… cut at a control character, and this tool's recorded connection is found before the name in status and every lookup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pt only their own GitHub program, only exact generated names are renamed, and jira-cli's bearer setup supplies the personal access token Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…token page, and the jira-cli bearer token is pinned as not a Cloud token Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a redirect with a credential, and Jira is detected from every token variable connect reads Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
1 similar comment
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
There was a problem hiding this comment.
4 issues found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/test/altimate/integrations.test.ts">
<violation number="1">
P2: This test covers only `JIRA_PAT_TOKEN`, not “any token variable” supported by detection. Exercise every supported variable, or parameterize the case, so regressions in the other detection sources are caught.</violation>
<violation number="2">
P2: This second connect's result is discarded, so the test passes even if the retained cloud-variant connect fails. Assert that the call returns `status: "connected"` before checking the variant.</violation>
</file>
<file name="packages/opencode/src/altimate/integrations/core.ts">
<violation number="1" location="packages/opencode/src/altimate/integrations/core.ts:1335">
P2: In mock/demo mode, `disconnectLocal` also removes the simulated workspace connection, so `disconnect --local-only` does not leave the workspace copy intact. Preserve the mock remote in this branch; local-only must clear only machine credentials.</violation>
</file>
<file name="packages/opencode/src/altimate/integrations/backend.ts">
<violation number="1" location="packages/opencode/src/altimate/integrations/backend.ts:45">
P1: `redactSecrets` skips credentials shorter than six characters, but `backendConfig` accepts any non-empty backend token. A short token can therefore be echoed by a transport error; redact the complete secret regardless of length and apply any minimum only to incidental fragments.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| * character (Bun's invalid-header error does), so each such piece is taken out as well as the whole value. | ||
| */ | ||
| export function redactSecrets(text: string, secrets: string[]): string { | ||
| const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter((v) => v.length >= 6) |
There was a problem hiding this comment.
P1: redactSecrets skips credentials shorter than six characters, but backendConfig accepts any non-empty backend token. A short token can therefore be echoed by a transport error; redact the complete secret regardless of length and apply any minimum only to incidental fragments.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/integrations/backend.ts, line 45:
<comment>`redactSecrets` skips credentials shorter than six characters, but `backendConfig` accepts any non-empty backend token. A short token can therefore be echoed by a transport error; redact the complete secret regardless of length and apply any minimum only to incidental fragments.</comment>
<file context>
@@ -37,6 +37,15 @@ export interface Connection {
+ * character (Bun's invalid-header error does), so each such piece is taken out as well as the whole value.
+ */
+export function redactSecrets(text: string, secrets: string[]): string {
+ const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter((v) => v.length >= 6)
+ return [...new Set(pieces)].sort((a, b) => b.length - a.length).reduce((m, v) => m.split(v).join("<redacted>"), text)
+}
</file context>
| const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter((v) => v.length >= 6) | |
| const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter(Boolean) |
| @@ -0,0 +1,3658 @@ | |||
| import { afterAll, afterEach, describe, expect, spyOn, test, beforeEach } from "bun:test" | |||
There was a problem hiding this comment.
P2: This test covers only JIRA_PAT_TOKEN, not “any token variable” supported by detection. Exercise every supported variable, or parameterize the case, so regressions in the other detection sources are caught.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/test/altimate/integrations.test.ts, line 2237:
<comment>This test covers only `JIRA_PAT_TOKEN`, not “any token variable” supported by detection. Exercise every supported variable, or parameterize the case, so regressions in the other detection sources are caught.</comment>
<file context>
@@ -2121,6 +2192,79 @@ describe("credentials flow", () => {
+ })
+
+ test("Jira is detected from any token variable connect reads", () => {
+ process.env.JIRA_PAT_TOKEN = GOOD
+ try {
+ expect(core.scan().find((d) => d.id === "jira")?.source).toEqual({ kind: "env", label: "JIRA_PAT_TOKEN" })
</file context>
| @@ -0,0 +1,3658 @@ | |||
| import { afterAll, afterEach, describe, expect, spyOn, test, beforeEach } from "bun:test" | |||
There was a problem hiding this comment.
P2: This second connect's result is discarded, so the test passes even if the retained cloud-variant connect fails. Assert that the call returns status: "connected" before checking the variant.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/test/altimate/integrations.test.ts, line 2166:
<comment>This second connect's result is discarded, so the test passes even if the retained cloud-variant connect fails. Assert that the call returns `status: "connected"` before checking the variant.</comment>
<file context>
@@ -2112,6 +2132,57 @@ describe("credentials flow", () => {
+ expect((await creds.connectCredentials({ id: "jira", variant: "cloud", localOnly: true })).status).toBe("connected")
+ await creds.setDraft("jira", "jiraBaseUrl", "https://jira.corp.example")
+ await token("jira", "jiraApiToken")
+ await creds.connectCredentials({ id: "jira", localOnly: true })
+ expect(core.loadStore().providers.jira?.variant).toBe("cloud")
+ // fields and the token page follow the same variant as connect.
</file context>
| import { afterAll, afterEach, describe, expect, spyOn, test, beforeEach } from "bun:test" | |
| expect((await creds.connectCredentials({ id: "jira", localOnly: true })).status).toBe("connected") |
| return withLock(async () => { | ||
| // Asked for explicitly: the workspace copy, wherever it is, is left alone and only this machine is cleared. | ||
| if (opts.localOnly) { | ||
| const removedLocal = await disconnectLocal(id) |
There was a problem hiding this comment.
P2: In mock/demo mode, disconnectLocal also removes the simulated workspace connection, so disconnect --local-only does not leave the workspace copy intact. Preserve the mock remote in this branch; local-only must clear only machine credentials.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/integrations/core.ts, line 1335:
<comment>In mock/demo mode, `disconnectLocal` also removes the simulated workspace connection, so `disconnect --local-only` does not leave the workspace copy intact. Preserve the mock remote in this branch; local-only must clear only machine credentials.</comment>
<file context>
@@ -1303,9 +1326,16 @@ export interface DisconnectResult {
return withLock(async () => {
+ // Asked for explicitly: the workspace copy, wherever it is, is left alone and only this machine is cleared.
+ if (opts.localOnly) {
+ const removedLocal = await disconnectLocal(id)
+ await creds.discardDraftSecrets(id)
+ return { removedLocal, removedRemote: 0, detached: true }
</file context>
| const validatedAt = (c: backend.Connection) => Date.parse(c.last_validated_at ?? "") || 0 | ||
|
|
||
| /** The connection this tool manages for a provider: matched on integration and name. */ | ||
| /** This tool's connection for a provider: the one recorded on this backend first (it may have been renamed), else the one named for this machine. */ |
There was a problem hiding this comment.
[SUGGESTION]: Duplicate doc block for findManaged
Line 595 still carries the old /** The connection this tool manages for a provider: matched on integration and name. */, and this new block repeats it. The new text also says "the one recorded on this backend first", which only holds when the caller passes recorded; otherwise the match is by name. Delete the line 595 comment and document the recorded parameter in the remaining one.
| // The connection this machine recorded on this backend comes first, so a changed host name updates it instead of adding another. | ||
| const own = backend.ownConnections(visible) | ||
| const rec = loadStore().providers[id] | ||
| const recorded = rec?.connectionId != null && rec.connectionBackend === backendKey(cfg) ? own.find((c) => c.id === rec.connectionId && c.integration_id === INTEGRATION_IDS[id]) : undefined |
There was a problem hiding this comment.
[SUGGESTION]: The recorded-connection lookup is duplicated
findManaged now takes the recorded id, and recordedIds(cfg) builds exactly this per-provider map for the current backend (used by statusRemote and managedInWorkspace), yet this block re-implements the condition inline and removeManaged does it a third time at line 1403. Replacing lines 1017-1018 with const existing = findManaged(own, id, os.hostname(), rec?.connectionBackend === backendKey(cfg) ? (rec.connectionId ?? null) : null) keeps the recorded-first rule in one place.
| if (opts.localOnly) { | ||
| const removedLocal = await disconnectLocal(id) | ||
| await creds.discardDraftSecrets(id) | ||
| return { removedLocal, removedRemote: 0, detached: true } |
There was a problem hiding this comment.
[SUGGESTION]: --local-only still removes the mock workspace copy
disconnectLocal ends with removeMockRemote(id) (line 1370), so in mock/demo mode this branch deletes the simulated workspace connection, while it reports removedRemote: 0 and the CLI prints "any workspace copy was left in place". This branch needs a local-only clear that leaves the mock workspace stand-in alone, e.g. by splitting the local purge from the mock-remote removal.
Issue for this PR
No linked issue. Stacked on #1609. The Claude Code plugin side is AltimateAI/altimate-claude-plugin#12.
Type of change
What does this PR do?
Adds
altimate integrationsso GitHub, Jira and Linear can be connected from the terminal, using the same credential fields as the Altimate workspace web form, instead of setting them up in the web app. Stacked on #1609.gh's github.com login, jira-cli,JIRA_API_TOKEN,LINEAR_API_KEY, and MCP servers in Claude Code's config (GitHub's only in one of GitHub's official setups). A project.mcp.jsononly shows that a provider is present; its values are never used, and a Jira site and token must come from the same source.fields <provider>: the form fields from the workspace's integrations catalog. They are cached, with a built-in fallback, and pre-filled from the machine. Secrets are reported only as a masked tail.set/set-secret --from-clipboard | --from-env | --stdin: fills fields. A secret is read by the CLI itself and never printed.connect <provider> [--local-only] [--share]: validates directly with GitHub, Jira or Linear, then either keeps the credential in the OS keychain or saves it as a connection in the user's own account and attaches it to the linked workspace. A rejected credential shows the provider's message and stores nothing.--share: attaching to a workspace that is not private (or doesn't say) lets its members use the connection, soconnect,updateandsynconly do it with--share. Without it nothing is written to the workspace, the connection stays in the user's account, and the result namesaltimate integrations sync <provider> --share. The check uses the workspace as read right before writing. A connection the workspace already uses stays attached, unless the write would promote it from a secondary connection to the entry's default. A connection that is already shared (its ownprivacyis notprivate, or missing) is not rewritten in place without--shareeither: the refusal comes before any write and namesupdate <provider> --shareorsync <provider> --share. Output says(private)only when neither the workspace nor the connection is shared, otherwise who can use it, also on a failure after a shared rewrite, and--jsoncarriesshared: true.update <provider>: replaces a rejected token on the same connection.status: reportsrejectedwhen a token stopped working.open-token-page,sync,block/unblock,disconnect(removes the local copy and the workspace connection this tool made).connect --local-only(Keep local) moves a workspace copy here and stays local untilunblock.blockrefuses a synced connection.Flocklock, as temp file plus rename. The state file and the secrets file (outside macOS) are mode0600. The catalog cache and the mock-remote file hold no secrets and use the default mode.security -ireads them from stdin.statusreportsworkspace.signedIn.--json, which the Claude Code plugin reads.Known limitations and follow-ups
Linux and Windows: a kept-local secret goes to a
0600file, not an OS keychain. Spec AC5 asks for the keychain only; this needs libsecret and DPAPI support.Connection identity: a managed connection is matched by its name,
Provider (from <hostname>), not asource.machinefield. Renaming the host orphans it, and fixing that needs a backend field. Keychain keys are not yet namespaced per Altimate tenant. Two machines with the same hostname also share one connection.Org policy "local only": not built. The backend has no policy source yet.
Workspace integrations list: the backend only replaces the whole list (
PATCH /datamates/{id}). The CLI re-reads it just before writing, but two concurrent writers can still race until there is an incremental or conditional update.Values starting with
-:integrations setcan't take one, because the argument parser reads it as a flag.Token expiry: shown for GitHub only. Jira and Linear don't report it.
After a failed workspace removal: when Keep local can't remove the workspace copy, the credential is kept here and a warning says so, but status doesn't yet show both copies coherently.
Rollback: restoring the previous secrets after a failed keychain write is best effort. A failed restore is not reported.
Secret-name fallback: treating catalog fields with known secret names as secret applies only to freshly fetched catalogs, not to a cached one.
Privacy re-check race: nothing ties the integrations PATCH to the privacy just read. If the workspace becomes public between that read and the write, the connection is widened and the result still says private. The exposure equals the normal order (a privacy change widens every default connection); only the report is stale. A real fix needs a conditional write in the backend.
Delete promotes a secondary:
disconnectand Keep local delete the managed connection through the backend's delete rule, the same one the web app uses: if a shared workspace's entry also enables another of the owner's connections, the lowest remaining one becomes the default and is widened to the workspace's audience. The owner enabled that connection in that shared workspace, which is why attaching one there as a secondary already needs--share. A warning naming the promoted connection is a follow-up.GitHub sources: only github.com is supported; GitHub Enterprise Server is a follow-up. A GitHub token is validated against api.github.com, so it is read only from a source that is for github.com:
gh's own stored github.com login (ghruns withoutGH_TOKEN,GITHUB_TOKEN,GH_HOSTand the enterprise token variables, with--hostname github.com), GitHub's official MCP setups word for word (docker with GitHub's image,npx @modelcontextprotocol/server-github, thegithub-mcp-serverbinary) where no host setting in the server, the shell or any Claude Code settings file names another host, or a token entered here. The shell'sGITHUB_TOKEN/GH_TOKENare not read: they can hold a token for any host. A token found only there, or in an unofficial MCP setup, is entered once withconnect github.Another Altimate sign-in: a connection id is recorded with the backend it belongs to. While the recorded workspace copy is on another sign-in,
connect,update,sync, Keep local anddisconnectrefuse and change nothing, andstatussays where it is.Secondary-only attach: appending this connection as a secondary to a shared workspace's entry is refused without
--share, and reported as shared with it, although the backend widens only defaults. Kept conservative: deleting the default later promotes and widens it.Plugin: the Claude Code plugin has no
--sharecontrol yet. On a shared workspace, its Link workspace and Sync all show the refusal reason.Lock and slow backends: a command holds the local lock across its workspace calls (20 s timeout each), while another command waiting for the lock gives up after 30 s. Only a slow backend hits this.
Review follow-ups (minor, deferred): a typed Jira site can be paired with a detected token from another source;
acliand the Linear CLI are shown as syncable though no credential is read from them; only~/.config/.jira/.config.ymlis read for jira-cli; Keep local with an unreachable provider replaces a valid workspace copy with an unverified one; a 4xx meaning bad input is classed as unreachable; a local record whose workspace update was marked invalid is not tracked; status judges a kept-local credential by whichever connection is shown; detach doesn't treat an unknown link the way attach does; a keychain write isn't read back; request abort and malformed-body handling and the real clipboard/stdin adapters have no checked-in tests.Outside this PR (pre-existing, noted for follow-up):
workspace/resend-hint.tsdoes not shell-quote skill names;native/dbt/project-lineage.tsparses a column likefrom1as the keywordfrom.Partial-failure edge cases: if
synccan't remove a legacy local key after an upload, re-runningsyncdoesn't retry that one key. In text mode, the cleanup warning is hidden when the workspace attach fails at the same time.Env overrides:
ALTIMATE_INTEGRATIONS_*backend and API variables (andJIRA_BASE_URLpairing) are honoured in every build. Tests and the local-backend setup rely on them; they should only apply under mock mode or in test builds.Stale connection ids: attach replaces an entry whose connection id is missing from every connection the user can see. Telling a deleted connection from one the user can't see needs a backend rule.
Draft secret names: drafts are not recorded by field name, so a draft for a field the workspace catalog later drops is not found by
discardordisconnect.Unreadable login on disconnect: for a record that isn't synced, the workspace step is skipped, so a copy that exists only in the workspace is left in place.
Signed-out disconnect after a failed Keep local removal: it reports success while the workspace copy remains.
Draft writes: a field typed with
setwhile a connect is being checked isn't part of the credential comparison; only the stored credential is.Plugin: the pane doesn't yet show
workspaceUnchecked(a failed workspace lookup in status), so counts can look synced when the workspace wasn't read.Pre-existing issues seen during review, in code from #1609 (not changed here):
api/client.tssignOut: a failedwithdrawClaudeSkillsis swallowed, with no warning or retry.cli/cmd/link.ts: picking the workspace that's already linked returns before the--claude-mdwrite, and a failed CLAUDE.md write is swallowed by an emptycatch.mcp-server/adapter.ts: tables beyondMAX_FUSED_TABLESare dropped silently.tool-cli/workspace-tools.ts:projectIsLinkedignoresALTIMATE_DISABLE_WORKSPACE.tool-cli/claude-md.ts: there's a window between thelstatcheck and the CLAUDE.md write.cli/cmd/tool.ts: the connections stamp uses only mtime and size.tools/sql-result-format.ts:csvCelldoesn't neutralise=,+,-and@prefixes.workspace/client.ts: setup reads credentials before the disabled check.session/analyst-effort.ts: an unknown explicit variant skips the analyst default.How did you verify your code works?
bun test test/altimate/integrations.test.ts: 238 pass, 0 fail. Every test case is listed below.bun test test/altimate: 11,692 pass, 1 fail (an unrelatedreview.test.tstiming case that passes alone).tsgo --noEmit(the packagetypecheck) is clean.api.github.comwith nothing sent to Altimateset-secret, and a bad GitHub token rejected with the provider's 401, with no secret left on disk.All 238 test cases in
test/altimate/integrations.test.ts(grouped bydescribeblock):sameRecord (1)
GitHub host policy (2)
detection parsing (3)
status (3)
block policy and sync (1)
a block set while a mock sync runs (1)
expiry (2)
keychain (9)
state file (1)
state files that are not objects (1)
secret storage (1)
workspace connections (71)
failure descriptions (3)
backend answers that are not what they should be (3)
jira domain and cli flags (2)
credentials flow › fields (6)
credentials flow › set and set-secret (5)
credentials flow › where Jira values may come from (8)
credentials flow › validators (9)
credentials flow › connect and update (85)
credentials flow › rejected status (3)
credentials flow (1)
catalog fields a person fills in (1)
attachToIntegrations (2)
attach keeps another connection (7)
collectConfig (1)
detachFromIntegrations (1)
the CLI passes --share through and reports shared (1)
printed text and catalog shape (3)
saved login (1)
Cost side effects
None. There are no model calls and no warehouse queries. Each command makes a fixed, small number of REST calls: to GitHub, Jira or Linear to validate a credential, and to the Altimate workspace API for connections and the integrations catalog. Nothing grows with user data.
Screenshots / recordings
Not applicable. This is a CLI change; the UI is in AltimateAI/altimate-claude-plugin#12.
Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit